package edu.xhu.behavior.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.xhu.model.behavior.pojos.BiliUserComment;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Map;

@Mapper
public interface BiliUserCommentMapper extends BaseMapper<BiliUserComment> {

    /**
     * 根据视频ID和偏移量,分页根据热度或时间查询根评论,每次返回pageSize条
     */
    List<BiliUserComment> queryCommentListPaged(long videoId, int shift, int pageSize);

    /**
     * 根据视频id,返回视频的根评论,根据热度/时间排序
     *
     * @param videoId
     * @param loveWeight
     * @param commentWeight
     * @param offset        偏移量(pageNo-1)*pageSize
     * @param pageSize      页面大小
     * @param sortByHotness true:热度排序, false:时间排序
     * @return 每条记录的map, {score=6493.85,user_id=274892974465220608,comment_id=286141391002664960,video_id=282617275427586048, ... ,is_delete=0}
     */
    List<Map<String, Object>> queryRootCommentsByVideoIds(Long videoId, double loveWeight, double commentWeight, Integer offset, Integer pageSize, Boolean sortByHotness);


    /**
     * 根据视频id，返回该视频所有根评论的id以及相应的热度值和时间，(热度/时间排序)
     */
    List<Map<String, Object>> queryRootCommentIdsByVideoId(Long videoId, double loveWeight, double commentWeight, Boolean sortByHotness);

    /**
     * 根据评论id,获取根评论(包含热度值)
     *
     * @return
     */
    List<Map<String, Object>> queryRootCommentsByCommentIds(List<Long> commentIds, double loveWeight, double commentWeight);

    /**
     * api-返回根评的所有子评，时间顺序
     */
    List<Map<String, Object>> querySonCommentsByRootIds(List<Long> rootIds);

    /**
     * 将指定根评论的子评论数量+1
     *
     * @param rootCommentId 根评论id
     */
    void increSonCommentCount(Long rootCommentId);

    /**
     * 测试,不管
     */
    List<BiliUserComment> pageList(int start, int rows);

}
